﻿import ko = require("knockout");
import Track = require("../../Track");

class RenameTrackDialog {
    public constructor(public params: { track: KnockoutObservable<Track> }) {
        params.track.subscribe((track) => {
            this.nameObservable(track.name);
            this.colorObservable(track.color);
        });
    }

    nameObservable: KnockoutObservable<KnockoutObservable<string>> = ko.observable(ko.observable(""));

    colorObservable: KnockoutObservable<KnockoutObservable<string>> = ko.observable(ko.observable(""));
    private palette = [
        "Grey",
        "Almond",
        "Red",
        "Orange",
        "LightGreen",
        "ForestGreen",
        "Azure",
        "Teal",
        "Blue",
        "Violet",
        "Pink",
        "Yellow"
    ].map((value) => ({
        "setColor": () => { this.setColor(value); },
        "cssClass": 'theme-' + value.toLowerCase() + " bd-bg2 bg-fg1"
    }));

    setColor(value: string) { this.colorObservable()(value); }

}

export = RenameTrackDialog;